package com.cl.it.utils;

import org.apache.commons.lang3.math.NumberUtils;
import org.apache.commons.text.StringEscapeUtils;

import java.util.List;

public class StringUtils {
    public static String regx(String source,String pattern){
        return ExtractUtils.getFirstMatcher(source, pattern, true);
    }

    public static String regx(String source,String pattern,int groupIndex){
        return ExtractUtils.getFirstMatcher(source, pattern, groupIndex);
    }

    public static List<String> regx(String source, String pattern, List<Integer> groups){
        return ExtractUtils.getFirstMatcher(source, pattern, groups);
    }

    public static List<String> regxs(String source,String pattern){
        return ExtractUtils.getMatchers(source, pattern, true);
    }
    public static List<String> regxs(String source,String pattern,int groupIndex){
        return ExtractUtils.getMatchers(source, pattern, groupIndex);
    }

    public static List<List<String>> regxs(String source,String pattern,List<Integer> groups){
        return ExtractUtils.getMatchers(source, pattern, groups);
    }
    public static Integer toInt(String source,int defaultValue){
        return NumberUtils.toInt(source, defaultValue);
    }

    public static Integer toInt(String source){
        return NumberUtils.toInt(source);
    }

    public static Double toDouble(String source){
        return NumberUtils.toDouble(source);
    }

    public static Long toLong(String source){
        return NumberUtils.toLong(source);
    }


    public static String unescape(String source){
        return StringEscapeUtils.unescapeJava(source);
    }
}
